<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport"
	content="width=device-width, initial-scale=1, maximum-scale=1">
<title>表单</title>

<link rel="stylesheet"
	href="/v1/xtj-wechat/static/js/layui-v2.5.6/layui/css/layui.css" media="all">

<style>



</style>
</head>
<body class="body">
	

	<form class="layui-form layui-from-pane" action="/addCollector"
		style="margin-top: 20px" method="post">
		<div class="layui-form-item">
			<label class="layui-form-label">活动名称</label>
			<div class="layui-input-block">
				<input type="text" name="name" lay-verify="required"
					lay-reqtext="活动名称是必填项，岂能为空？" placeholder="请输入" autocomplete="off"
					class="layui-input">
			</div>
		</div>

		<div class="layui-form-item" style="margin-top: 40px">
			<div class="layui-input-block">
				<button class="layui-btn  layui-btn-submit " lay-submit=""
					lay-filter="demo1">立即提交</button>
				<button type="reset" class="layui-btn layui-btn-primary">重置</button>
			</div>
		</div>
	</form>
	<script type="text/javascript"
		src="/v1/xtj-wechat/static/js/layui-v2.5.6/layui/layui.js"></script>
	<script type="text/javascript" src="/v1/xtj-wechat/static/js/jquery.min.js"></script>
	<script>
    layui.use(['form','layer','jquery'], function(){
        var form = layui.form
                ,layer = layui.layer
                 ,$=layui.jquery,
                  table= layui.table
        //监听提交
        form.on('submit(demo1)', function(data){
            //layer.alert(JSON.stringify(data.field))
              //data=JSON.stringify(data.field)
            $.ajax({
                url:'/v1/xtj-wechat/xtjActivity/ActivityAdd',
                type:'POST',
                dataType:'json',
               data:{name:data.field.name},
                 success:function (msg) {
                    var returnCode=msg.code;
                    if(returnCode==200){
                        layer.closeAll('loading');
                        layer.load(2);
                        layer.msg("添加成功", {icon: 6});
                        setTimeout(function(){
                            window.parent.location.reload();//修改成功后刷新父界面
                        }, 1000);
                           //加载层-风格

                    }else{
                        layer.msg("已经存在该设备,不支持重复添加", {icon: 5});
                    }
                }
            })
            return false;
        });
    });
</script>
</body>
</html>
